Skip to content

fix(settings): accept a permission mode only for photos - #5006

Merged
thymikee merged 2 commits into
callstack:mainfrom
imranbarbhuiya:fix/settings-permission-mode-photos-only
Nov 23, 2026
Merged

thymikee merged 2 commits into
callstack:mainfrom
imranbarbhuiya:fix/settings-permission-mode-photos-only

Conversation

@imranbarbhuiya

@imranbarbhuiya imranbarbhuiya commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Every mobile settings permission target accepted the full|limited modes. So an app id typed where --app belongs (settings permission deny notifications com.example.app) was refused as a bad mode, and when the output was discarded the change silently never happened. Only iOS photos honours a mode, and the runtimes already refuse one for every other target.

Now:

  • photos has its own form with the modes.
  • Other targets refuse a fourth positional with "takes no mode".
  • On app-scoped targets, a value that looks like a bundle or package id is refused with reason: setting_permission_app_positional, dispatched: no, the app in details.app, and the hint Pass the app with --app <id>.
  • The code stays INVALID_ARGS.

Before / after

Android emulator (Pixel 9 AVD, Android 16):

$ settings permission deny notifications com.android.chrome
base a4f2dcad0: INVALID_ARGS: settings permission mode must be full|limited.
head 1f9f64e1d: INVALID_ARGS: settings permission notifications takes no mode. Not dispatched. Next: Pass the app with --app com.android.chrome.
$ settings permission grant notifications --app com.android.chrome
head: Updated setting: permission
$ settings permission grant accessibility com.android.chrome     # macOS-only target, so no --app hint
head: INVALID_ARGS: settings permission accessibility takes no mode.

Validation

  • Head 1f9f64e1d, check:affected --run --head, exactCommit: true (same result at 0bac0145b). Format, lint, typecheck, layering, fallow, build and vitest-related pass. unit fails only on upload-http-deadline and committed-source-tree, which fail the same way on clean main on this macOS host.
  • The new settings.test.ts cases fail at base.

Every mobile permission target shared one form with full|limited modes,
so an app id placed after `notifications` was refused as a bad mode.
Only photos honours a mode (iOS photos-add); Android and the other iOS
targets refuse one at runtime.

Give photos its own form with the modes, so the other mobile targets
refuse a fourth positional with "takes no mode", and a valid photos mode
followed by another positional is refused as "takes one mode". When an
app-scoped target gets a value that looks like a bundle id or package,
the refusal says to pass it with --app.
@thymikee

Copy link
Copy Markdown
Member

Thanks for the fix. The change at 0bac014 is ready: the parser now accepts a permission mode only for photos, and the code paths read as correct. Not blocking, and these can be taken or left: the --app <id> guidance is built into the error message text instead of a typed reason and hint like settingsAppNotConsumedRefusal (settings.ts:338), the "requires a target" list is rebuilt from two target lists instead of the forms (settings.ts:325), and SettingsUpdateOptions still types mode for every target, so { permission: 'camera', mode: 'limited' } only fails at runtime (client-settings.ts:80). The only non-passing checks are two cancelled Body rules runs, and a third Body rules run on this PR passed. That job checks the PR body and does not exercise this diff, so the cancelled runs look unrelated. There are no conflicts. Not verified here: the Android emulator output in the PR body, the claim that the upload-http-deadline and committed-source-tree unit failures also happen on main, and a regenerated commands.md block, which was compared by reading only.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 23, 2026
@imranbarbhuiya

Copy link
Copy Markdown
Contributor Author

Thanks! I took the first two in 1f9f64e:

  • The --app guidance is now a typed refusal: reason: setting_permission_app_positional, dispatched: no, the app in details.app, and the hint Pass the app with --app <id>.
  • The "requires a target" list now comes from the forms.

I left the SettingsUpdateOptions narrowing out of this PR. It changes a public type, so existing callers passing { permission: 'camera', mode: 'limited' } would stop compiling. Happy to send it separately if you want it.

@thymikee thymikee removed the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 23, 2026
@thymikee

Copy link
Copy Markdown
Member

Thanks for the follow-up. The PR is ready at 1f9f64e: the earlier clean review at 0bac014 (#5006 (comment)) still holds, and the delta code and its test read correctly. Not blocking: when a caller sends positionals straight to the daemon, such as ["permission","deny","notifications","com.example.app"], parseSettingsArgs in https://github.com/callstack/agent-device/blob/1f9f64e/packages/daemon/src/execution/handlers/snapshot-settings.ts#L75 returns errorResponse(error.code, error.message) and drops the typed details and hint, so that caller no longer sees the --app guidance; the CLI route is not affected, and this can be taken or left, for example by passing the details through as the app-not-consumed refusal does. The Smoke Tests failure looks unrelated: it is the apt-get update timeout in the Linux desktop dependencies step, which fails before any agent-device code runs, so it needs a re-run, not a code change. Body rules was cancelled after an earlier run passed, and the check:affected run for this commit is still queued. There are no conflicts. Before merge, re-run Smoke Tests and wait for Body rules and check:affected to pass. Not verified here: the tests, the generate:reasons check and the emulator were not run, and the Android output and base-failure claims in the PR body date from 0bac014.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 23, 2026
@thymikee
thymikee merged commit a878839 into callstack:main Nov 23, 2026
15 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants